package com.ctg.behavior.calc.impala.builder.addictions;

import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;

import com.ctg.behavior.common.calc.CtCalcPropertyType;
import com.ctg.behavior.common.consts.CtFieldConsts;

@Component
public class CtAddictionsRowKeyBuilder {

	public String buildRowKey(CtCalcPropertyType byProperty, Map<String, Object> oneResult) {
		StringBuilder sbuilder = new StringBuilder("RK").append("@");
		if (!StringUtils.isEmpty(byProperty.getProperty())) {
			sbuilder.append(oneResult.get(byProperty.getProperty()).toString());
		} else {
			sbuilder.append(oneResult.get(CtFieldConsts.FIELD_KEY_EVENT_DATE).toString());
		}
		return sbuilder.toString();
	}

	public String buildRowCellKey(String rowKey, Integer rowCellIndex) {
		StringBuilder sbuilder = new StringBuilder(rowKey);
		sbuilder.append(rowCellIndex);
		return sbuilder.toString();
	}

}
